package javaTest;

import java.util.Scanner;

public class Student {
    private int sNO;
    private String sName;
    private String sSex;
    private int sAge;
    private int sJava;

    public int getsNO() {
        return sNO;
    }

    public void setsNO(int sNO) {
        this.sNO = sNO;
    }

    public String getsName() {
        return sName;
    }

    public void setsName(String sName) {
        this.sName = sName;
    }

    public String getsSex() {
        return sSex;
    }

    public void setsSex(String sSex) {
        this.sSex = sSex;
    }

    public int getsAge() {
        return sAge;
    }

    public void setsAge(int sAge) {
        this.sAge = sAge;
    }

    public int getsJava() {
        return sJava;
    }

    public void setsJava(int sJava) {
        this.sJava = sJava;
    }

    public Student(int sNO, String sName, String sSex, int sAge, int sJava) {
        this.sNO = sNO;
        this.sName = sName;
        this.sSex = sSex;
        this.sAge = sAge;
        this.sJava = sJava;
    }

    public Student() {
    }

    public void display() {
        System.out.println("学号：" + sNO + "  姓名:" + sName + "  性别" + sSex + "  年龄" + sAge + "  成绩" + sJava);
    }

    public static void main(String[] args) {
        //将五个学生输入进去
        Student s1 = new Student(1, "张三", "男", 21, 85);
        Student s2 = new Student(2, "李四", "男", 19, 80);
        Student s3 = new Student(3, "王五", "男", 20, 60);
        Student s4 = new Student(4, "赵六", "男", 20, 90);
        Student s5 = new Student(5, "张七", "男", 19, 55);
        Student[] student = {s1,s2,s3,s4,s5};
//        键盘输入法
//        Scanner input = new Scanner(System.in);
//
//        Student[] student = new Student[5];
//        for (int i = 0; i < student.length; i++) {
//            System.out.println("\n-------请输入第" + (i + 1) + "个学生信息------");
//            System.out.println("请输入学号");
//            int sNo = input.nextInt();
//            System.out.println("请输入姓名");
//            String sName = input.next();
//            System.out.println("请输入性别");
//            String sSex = input.next();
//            System.out.println("请输入年龄");
//            int sAge = input.nextInt();
//            System.out.println("请输入成绩");
//            int sJava = input.nextInt();
//
//            //定义数组存储五位学生
//            student[i] = new Student(sNo, sName, sSex, sAge, sJava);
//        }
        //定义平均值
        int avg = 0;
        //定义最值
        int max = 0, min = student[0].getsJava();
        System.out.println("--------------学生信息表--------------");
        for (Student st : student) {
            st.display();
            //取成绩值
            int score = st.getsJava();
            if (max < score) {
                max = score;
            }
            if (min > score) {
                min = score;
            }
            avg += score;
        }
        System.out.println("-----------------------------------");
        System.out.println("-------------学生成绩表--------------");
        System.out.println("平均值为：" + avg / 5);
        System.out.println("最大值为：" + max);
        System.out.println("最小值为：" + min);
        System.out.println("------------------------------------");
    }
}
